package com.cpecc.manager.wuzi;

import com.cpecc.dao.wuzi.BaoFeiSPRDao;
import com.cpecc.model.system.User;
import com.cpecc.model.wuzi.BaoFeiSPR;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
@Transactional
public class BaoFeiSPRManager {
	
	@Autowired
	private BaoFeiSPRDao baoFeiSPRDao;
	
	public void save(BaoFeiSPR baoFeiSPR){
		baoFeiSPRDao.save(baoFeiSPR);
	}
	
	public boolean delete(String id){
		return baoFeiSPRDao.delete(id);
	}

	public List<BaoFeiSPR> getBfxgbmspList(User user){
		return baoFeiSPRDao.getBfxgbmspList(user);
	}

	public List<BaoFeiSPR> getMySPList(User user){
		return baoFeiSPRDao.getMySPList(user);
	}
	
	public List<BaoFeiSPR> getMyBMSPList(User user){
		return baoFeiSPRDao.getMyBMSPList(user);
	}

	public List<BaoFeiSPR> getGKBMSPList(User user){
		return baoFeiSPRDao.getGKBMSPList(user);
	}

	public List<BaoFeiSPR> getBaoFeiList(User user, Integer huangJieId) {
		return baoFeiSPRDao.getBaoFeiList(user, huangJieId);
	}

	public List<User> getSPRList(String baoFeiId){
		return baoFeiSPRDao.getSPRList(baoFeiId);
	}

	public List<User> getBuMenSPR(String baoFeiId){
		return baoFeiSPRDao.getBuMenSPR(baoFeiId);
	}
	
	public List<BaoFeiSPR> getBuMenSRRList(String baoFeiId){
		return baoFeiSPRDao.getBuMenSRRList(baoFeiId);
	}
	
	public List<BaoFeiSPR> getAllSPR(String baoFeiId){
		return baoFeiSPRDao.getAllSPR(baoFeiId);
	}
	
	public int getBySPSX(String userId,String baoFeiId){
		return baoFeiSPRDao.getBySPSX(userId,baoFeiId);
	}
	
	public boolean deleteSPR(String baoFeiId,String userId){
		return baoFeiSPRDao.deleteSPR(baoFeiId, userId);
	}
	
	public BaoFeiSPR get(String id){
		return baoFeiSPRDao.get(id);
	}
	
	public boolean deleteAllSPR(String baoFeiId){
		return baoFeiSPRDao.deleteAllSPR(baoFeiId);
	}
	
	public List<User> getLZSPR(String baoFeiId){
		return baoFeiSPRDao.getLZSPR(baoFeiId);
	}

	/**
	 * 审批人是否都已经审批
	 * @param baoFeiId		物资报废ID
	 * @return		false：否；true：是
	 */
	public boolean isOver(String baoFeiId) {
		List<BaoFeiSPR> list = baoFeiSPRDao.getAllByBaoFeiId(baoFeiId);
		return CollectionUtils.isEmpty(list);
	}

	public boolean updateSPRNO(String id) {
		return baoFeiSPRDao.updateSPRNO(id);
	}

}
